#include "lib/random.h"
#include <stdio.h>
#include <syscall.h>
#include "tests/arc4.h"
#include "tests/lib.h"
#include "tests/main.h"

#define ARR_SIZE  (1 << 12)*120 /4
int myarr[ARR_SIZE];
static void* get_page_addr(void* addr)
{
	return (void*)(((int)addr >> 12) << 12);
}
int main(void)
{
  random_init (0);
	int i, j, tmp;
	for (i = 0; i < ARR_SIZE ; i++)
	{
		myarr[i] = ARR_SIZE-i; 
	}
	for(i = 0; i < ARR_SIZE; i += ARR_SIZE/100)
	{
		j = random_ulong() % ARR_SIZE;
		printf("Frame Usage\n");
		frame_usage();
		printf("Frame Usage end\n");
		printf("Accessing userpage at %p, %p\n", get_page_addr(&myarr[i]), get_page_addr(&myarr[j]));
		tmp = myarr[i];
		myarr[i] = myarr[j];
		myarr[j] = tmp;
	}
	return 0;
}
